package com.yonyou.cyxdms.basedata.service.controller.region;

import com.yonyou.cyx.framework.controller.base.BaseController;
import com.yonyou.cyxdms.basedata.service.service.region.RegionService;
import com.yonyou.cyxdms.basedata.service.vo.region.SpAllCityInfoVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author guorp1
 * @since 2018-11-26
 */
@RestController
@RequestMapping("/city")
public class CityController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(CityController.class);

    @Autowired
    public RegionService cityService;


    /**
     * @param [forWord]
     * @return java.util.Map
     * @Description 带关键字搜索城市列表
     * @author liyuquan
     * @since 2019/1/24 11:32
     */
    @ResponseBody
    @GetMapping("/cityInfo")
    public Map<String, Object> cityInfo(@ApiParam(name = "forWord", value = "搜索关键字", required = false)
                                        @RequestParam(value = "forWord", required = false) String forWord) {
        logger.info("搜索关键字:{}", forWord);
        return cityService.cityInfo(forWord);
    }

    /**
     * 前端定置化接口
     * * @author houkh
     * * @since 20191130
     */
    @ResponseBody
    @GetMapping("/spCityInfo")
    @ApiOperation(value = "前端获取城市信息指定接口")
    @ApiImplicitParam(value = "租户ID", name = "appId", paramType = "header", dataType = "String")
    public SpAllCityInfoVO spCityInfo() {
        return cityService.spCityInfo();
    }
}